<%@ page contentType="text/html;charset=utf-8" language="java"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%> 
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<html:html>
<head>
		<META http-equiv=Content-Type content="text/html; charset=utf-8">
		<LINK href="styles/stylewang.css"  type=text/css rel=stylesheet>
		<LINK href="../styles/stylewang.css"  type=text/css rel=stylesheet>
		<LINK href="styles/sciencee.css"  type=text/css rel=stylesheet>
		<LINK href="../styles/sciencee.css"  type=text/css rel=stylesheet>
		
		<LINK href="xtree.css"  type=text/css rel=stylesheet>
		<style type="text/css">
		#Layer1 {
	position:absolute;
	width:1px;
	height:1px;
	z-index:1;
	visibility: inherit;
}
        </style>
		<title>CGProject</title>
		<html:base/>
</head>
  <script language="javaScript" src="../../js/calendar.js"></script>
<%String id = (String)request.getAttribute("ID");%>

<body>


<table border="0" width="100%" cellspacing="0" id="table6">
	<tr>
		<td colspan="5" width="85%" id="onlybt">&nbsp;
		<b><bean:message key="elementgroup"/>&nbsp;<font color="#990000"><bean:write name="egp" property="elementGroupName"/></font>&nbsp;<bean:message key="elementgroup.information"/></b>

		</td>
	</tr>
	<logic:equal name="egps_empty" value="false"><tr>
		<td  width="17%" id="btleftbian">
		<b>&nbsp; <bean:message key="elementgroup.subgroup"/></b></td>		
		<td width="53%" colspan="4" id="btrightbian">
		<b><font face="Verdana">&nbsp; </font></b></td>		
	</tr></logic:equal>
	<logic:equal name="egps_empty" value="true"><tr>
		<td width="17%"colspan="5" id="rightcenter">
		&nbsp;<font color="#990000"><bean:message key="elementgroup.nosubgroup"/></font></td>		
		
	</tr></logic:equal>
	<logic:iterate id="element" name="egps">
	<tr>
		<td width="17%" id="leftcenter">
		&nbsp;&nbsp;<bean:write name="element" property="elementGroupName"/></td>		
		<td width="53%" colspan="4" id="rightcenter">
		&nbsp;<html:link page="/intoModEGroup.do" paramId="EGroupID" paramName="element" paramProperty="elementGroupId">[<bean:message key="basicmodify"/>]</html:link>&nbsp;&nbsp;
		<a href="../del.do?FatherType=Elementgroup&FatherId=<%=id%> &Type=Elementgroup&Id=<bean:write name="element" property="elementGroupId"/>" onclick="return   confirm('Confirm Delete')">[<bean:message key="delete"/>]</a></td>		
	</tr>
	</logic:iterate>
	<logic:equal name="eles_empty" value="false"><tr>
		<td width="17%" id="btleftbian">
		<b>&nbsp; <bean:message key="element.name"/></b></td>
		<td width="17%" id="btcenterbian">
		<b>&nbsp; </b><bean:message key="element.planstarttime"/></td>
		<td width="17%" id="btcenterbian">
		<b>&nbsp; </b><bean:message key="element.planendtime"/></td>
		<td width="17%" id="btcenterbian">
		<b>&nbsp; </b><bean:message key="element.description"/></td>
		<td width="53%" id="btrightbian">
		<b><font face="Verdana">&nbsp; </font></b></td>		
	</tr></logic:equal>
	<logic:equal name="eles_empty" value="true"><tr>
		<td width="17%" id="leftcenter">
		&nbsp;<font color="#990000"><bean:message key="elementgroup.noelement"/></font></td>		
		<td width="53%" id="rightcenter">
		　</td>		
	</tr></logic:equal>
	<logic:iterate id="element" name="eles">
	<tr>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;<bean:write name="element" property="elementName"/></td>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;<bean:write name="element" property="planStartTime" format="yyyy-MM-dd"/></td>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;<bean:write name="element" property="planEndTime" format="yyyy-MM-dd"/></td>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;<bean:write name="element" property="elementDescription"/></td>		
			<td width="20%" id="rightcenter">
			<html:link page="/intoModElement.do" paramId="elementId" paramName="element" paramProperty="elementId">[<bean:message key="basicmodify"/>]</html:link>&nbsp;&nbsp;
			<a href="../del.do?FatherType=Elementgroup&FatherId=<%=id%> &Type=Element&Id=<bean:write name="element" property="elementId"/>" onclick="return   confirm('ConfirmDelete')">[<bean:message key="delete"/>]</a></td>		
	  </tr>
	</logic:iterate>
	<tr>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;</td>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;</td>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;</td>
			<td width="20%" id="leftcenter">
			&nbsp;&nbsp;</td>		
			<td width="20%" id="rightcenter">
			&nbsp;&nbsp;</td>		
	  </tr>
	<html:form action="/addElementGroup"  onsubmit="return submitAddElementGroup()">
	<html:hidden property="id" value="<%=id%>"/>
	<table border="0" width="100%" cellspacing="0" id="tabletable" cellpadding="0">
		<tr>
			<td width="8%" id="btleftbian"><font color="#990000">&nbsp;<bean:message key="elementgroup.addsubgroup"/></font></td>
			<td width="93%" id="btrightbian">
			<bean:message key="elementgroup"/></td>
		</tr>	


		<tbody id="tbDetailUsed">
		<tr>
			<td  width="8%" id="leftcenter"><input type="checkbox"  disabled name="record_select" ></td>
			<td width="93%" id="rightcenter">
			<html:text property="groupName" size="40" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
		</tr>	
	
	
		</tbody>
		
		<tr>
			<td width="100%" id="rightbottom" colspan="2">
			<input type="button" value='<bean:message key="submit" />' name="B1" style="font-family: Tahoma; font-size: 11px" onClick="submitAddElementGroup()">
			&nbsp;&nbsp;&nbsp;&nbsp;
			
		</tr>
		
		
	</table>
	<table id="tbDetailPrepare" style="display:none" cellspacing="0" cellpadding="0">
		<tr>
			<td width="8%" id="leftcenter"><input type="checkbox" name="record_select" ></td>
			<td width="93%" id="rightcenter">
			<html:text property="groupName" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
		</tr>
	</table>
	</html:form>
	<html:form action="/addElement">
	<html:hidden property="elementGroupId" value="<%=id%>"/>
	<table border="0" width="100%" cellspacing="0" id="tabletable" cellpadding="0">
		<tr >
			<td width="8%" id="btleftbian"><font color="#990000">&nbsp;<bean:message key="elementgroup.addelement"/></font></td>
			<td width="22%" id="btcenterbian">
			<bean:message key="element.name"/></td>
			<td  width="20%" id="btcenterbian">
			<bean:message key="element.planstarttime"/></td>
			<td width="20%" id="btcenterbian">
			<bean:message key="element.planendtime"/></td>
			<td width="30%" id="btrightbian">
			<bean:message key="element.description"/></td>

		</tr>	
		<script language="javascript">var i=0;</script>

		<tbody id="tbDetailUsed1">
		<tr>
			<td width="8%" id="leftcenter"><input type="checkbox" disabled  name="record_select" ></td>
			<td  width="22%" id="leftcenter">
			<html:text property="name" size="20" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
			<td  width="20%" id="leftcenter">
			<html:text property="startTime" size="20" readonly="true" onclick="showcalendar(event, this)" onfocus="showcalendar(event, this)" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/>
			</td>
			<td  width="20%" id="leftcenter">
			<html:text property="finishTime" size="20" readonly="true"  onclick="showcalendar(event, this)" onfocus="showcalendar(event, this)"style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/>
			</td>
			<td width="30%" id="rightcenter">
			<html:text property="description" size="20" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>

		</tr>	
	
		</tbody>
		
		<tr>
			<td  width="100%" id="rightbottom" colspan="5">
			<input type="button" value='<bean:message key="submit"/>' name="B1" style="font-family: Tahoma; font-size: 11px" onClick="submitAddElement()">
			
			
		</tr>
		
		
	</table>
	<table id="tbDetailPrepare1" style="display:none" cellspacing="0" cellpadding="0">
		<tr>
			<script language="javascript">i++</script>
			<td width="8%" id="leftcenter"><input type="checkbox" name="record_select" ></td>
			<td width="22%" id="leftcenter">
			<html:text property="name" size="20" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>
			<td width="20%" id="leftcenter">
			<html:text property="startTime" size="20" readonly="true"  onclick="showcalendar(event, this)" onfocus="showcalendar(event, this)" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/>
			</td>
			<td width="20%" id="leftcenter">
			<html:text property="finishTime" size="20" readonly="true"  onclick="showcalendar(event, this)" onfocus="showcalendar(event, this)" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/>
			</td>
			<td width="30%" id="rightcenter">
			<html:text property="description" size="20" style="border:1px solid #FFFFFF; font-family: Tahoma; font-size: 11px; padding-left:4px; padding-right:4px; padding-top:1px; padding-bottom:1px"/></td>

		</tr>	
	</table>
	</html:form>
</table>



</body>
</html:html>
<script language="javascript">
function submitAddElementGroup()
{
	var counter=tbDetailUsed.rows;
	var wrong_counter1=0;
	var wrong_counter2=0;
	for(var i=0;i<counter.length;i++)
	{
		if(document.addElementGroupForm.groupName[i].value=="")
		{
			alert("Please input "+(i+1)+"'s name");
			wrong_counter1++;
			break;
		}
	}
	for(var j=0;j<counter.length;j++)
	{
		for(var k=j;k<counter.length;k++)
		{
			if(document.addElementGroupForm.groupName[j].value==document.addElementGroupForm.groupName[k].value&&j!=k&&wrong_counter1==0)
			{
				alert(" "+(j+1)+" and "+(k+1)+"cannot use the same name!");
				wrong_counter2++;
				break;
			}

		}
	}
	if(wrong_counter1!=0||wrong_counter2!=0)
	{
		return;
	}
	document.addElementGroupForm.submit();
}
function submitAddElement()
{
	var counter=tbDetailUsed1.rows;
	var wrong_counter1=0;
	var wrong_counter2=0;
	var wrong_counter3=0;
	for(var i=0;i<counter.length;i++)
	{
		if(document.addElementForm.name[i].value=="")
		{
			alert("Please input "+(i+1)+" name");
			wrong_counter1++;
			break;
		}
	}
	for(var l=0;l<counter.length;l++)
	{
		if(document.addElementForm.startTime[l].value>document.addElementForm.finishTime[l].value)
		{
			alert("The clause "+(l+1)+" 's starttime is later than its endtime");
			wrong_counter3++;
			break;
		}
	}

	for(var j=0;j<counter.length;j++)
	{
		for(var k=j;k<counter.length;k++)
		{
			if(document.addElementForm.name[j].value==document.addElementForm.name[k].value&&j!=k&&wrong_counter1==0)
			{
				alert("The clause"+(j+1)+" and "+(k+1)+" cannot use the same name");
				wrong_counter2++;
				break;
			}

		}
	}
	if(wrong_counter1!=0||wrong_counter2!=0||wrong_counter3!=0)
	{
		return;
	}
	document.addElementForm.submit();
}

function addDetailProcess(afterRowIndex)		//增加明细
{
	
	
	var alltbDetailUsed = document.all("tbDetailUsed").rows;
	
	var theFirstSelectedDetail;
	if (afterRowIndex==null)
	{
	  theFirstSelectedDetail=alltbDetailUsed.length-2;
	}
	else theFirstSelectedDetail=afterRowIndex;
	var newRow = document.all("tbDetailPrepare").rows[0].cloneNode(true);
	var desRow = alltbDetailUsed[theFirstSelectedDetail+1];
//		desRow.parentElement.insertBefore(newRow,desRow );
	desRow.parentElement.appendChild(newRow);
	
	return alltbDetailUsed.length;
}
function addDetailProcess1(afterRowIndex)		//增加明细
{
	
	
	var alltbDetailUsed = document.all("tbDetailUsed1").rows;
	
	var theFirstSelectedDetail;
	if (afterRowIndex==null)
	{
	  theFirstSelectedDetail=alltbDetailUsed.length-2;
	}
	else theFirstSelectedDetail=afterRowIndex;
	var newRow = document.all("tbDetailPrepare1").rows[0].cloneNode(true);
	var desRow = alltbDetailUsed[theFirstSelectedDetail+1];
//		desRow.parentElement.insertBefore(newRow,desRow );
	desRow.parentElement.appendChild(newRow);
	
	return alltbDetailUsed.length;
}


function delDetailProcess()						//删除明细
{
	var tag="";
	var alltbDetailUsed = document.all("tbDetailUsed").rows;
	for(var ii=0;ii<alltbDetailUsed.length;ii++)
	{
		
		if (alltbDetailUsed[ii].all("record_select").checked==true)
		{
			tag="true";
			break;		
		}
		else
		{
			tag="false";
		}
	}
	if(tag=="false")
	{
		alert("Please select a clause");
	}
	else
	{
		for(var i=0;i<alltbDetailUsed.length;i++)
		{
			if (alltbDetailUsed[i].all("record_select").checked==true)
			{
				document.all("tbDetailUsed").deleteRow(i);
				i=i-1;
			}
		}
	}
}
function delDetailProcess1()						//删除明细
{
	var tag="";
	var alltbDetailUsed = document.all("tbDetailUsed1").rows;
	for(var ii=0;ii<alltbDetailUsed.length;ii++)
	{
		
		if (alltbDetailUsed[ii].all("record_select").checked==true)
		{
			tag="true";
			break;		
		}
		else
		{
			tag="false";
		}
	}
	if(tag=="false")
	{
		alert("Please selct a clause");
	}
	else
	{
		for(var i=0;i<alltbDetailUsed.length;i++)
		{
			if (alltbDetailUsed[i].all("record_select").checked==true)
			{
				document.all("tbDetailUsed1").deleteRow(i);
				i=i-1;
			}
		}
	}
}
</script>